package android.itv.library;

import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.itv.R;
import android.itv.view.Login;

public class NotificationBar extends BroadcastReceiver
{
    NotificationManager nm;
    Notification notify;
    
    @Override
    public void onReceive(Context context, Intent intent)
    {
	String content=intent.getStringExtra("NOTIFICATION");
	
	nm=(NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);
        notify=new Notification(R.drawable.ic_launcher, "",System.currentTimeMillis());
        Intent intent1=new Intent(context,Login.class);
        PendingIntent pendIntent=PendingIntent.getActivity(context, 0,intent1, 0);
        notify.setLatestEventInfo(context,context.getResources().getString(R.string.notification) , content, pendIntent);
        notify.flags=Notification.FLAG_AUTO_CANCEL;
        notify.defaults|=Notification.DEFAULT_SOUND|Notification.DEFAULT_LIGHTS;
        nm.notify(1, notify);
        Database database=new Database(context);
	database.deleteNotifications(content);
    }
    
}